Eclipse Platform
Pre-release 3.0

org.eclipse.jface.action
Class CoolBarManager

java.lang.Object
  extended byorg.eclipse.jface.action.ContributionManager
      extended byorg.eclipse.jface.action.CoolBarManager
All Implemented Interfaces:
IContributionManager, ICoolBarManager

public class CoolBarManager
extends ContributionManager
implements ICoolBarManager

A cool bar manager is a contribution manager which realizes itself and its items in a cool bar control.

This class may be instantiated; it may also be subclassed.

Since:
3.0
See Also:
#ICoolBarManager

Field Summary
static String USER_SEPARATOR
          A separator created by the end user.
 
Fields inherited from interface org.eclipse.jface.action.ICoolBarManager
SIZE, VISIBILITY
 
Constructor Summary
CoolBarManager()
          Creates a new cool bar manager with the default style.
CoolBarManager(CoolBar coolBar)
          Creates a cool bar manager for an existing cool bar control.
CoolBarManager(int style)
          Creates a cool bar manager with the given SWT style.
 
Method Summary
 void add(IToolBarManager toolBarManager)
          A convenience method to add a tool bar as a contribution item to this cool bar manager.
 CoolBar createControl(Composite parent)
          Creates and returns this manager's cool bar control.
 void dispose()
          Disposes of this cool bar manager and frees all allocated SWT resources.
 IMenuManager getContextMenuManager()
          Returns the context menu manager used by this cool bar manager.
 CoolBar getControl()
          Returns the cool bar control for this manager.
 boolean getLockLayout()
          Returns whether the layout of the underlying cool bar widget is locked.
 int getStyle()
          Returns the style of the underlying cool bar widget.
protected  void itemAdded(IContributionItem item)
          Subclasses may extend this ContributionManager method, but must call super.itemAdded.
protected  void itemRemoved(IContributionItem item)
          Subclasses may extend this ContributionManager method, but must call super.itemRemoved.
 void refresh()
          Synchronizes the visual order of the cool items in the control with this manager's internal data structures.
 void resetLayout()
          Restores the canonical order of this cool bar manager.
 void setContextMenuManager(IMenuManager contextMenuManager)
          Sets the context menu of this cool bar manager to the given menu manager.
 void setLayout(ArrayList newLayout)
          Replaces the internal data structure with the given new order.
 void setLockLayout(boolean value)
          Locks or unlocks the layout of the underlying cool bar widget.
 void update(boolean force)
          Subclasses may extend this IContributionManager method, but must call super.update.
 
Methods inherited from class org.eclipse.jface.action.ContributionManager
add, add, appendToGroup, appendToGroup, dumpStatistics, find, getItems, getOverrides, hasDynamicItems, indexOf, indexOf, insert, insertAfter, insertAfter, insertBefore, insertBefore, internalSetItems, isDirty, isEmpty, markDirty, prependToGroup, prependToGroup, remove, remove, removeAll, setDirty, setOverrides
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.action.IContributionManager
add, add, appendToGroup, appendToGroup, find, getItems, getOverrides, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, markDirty, prependToGroup, prependToGroup, remove, remove, removeAll
 

Field Detail

USER_SEPARATOR

public static final String USER_SEPARATOR
A separator created by the end user.

See Also:
Constant Field Values
Constructor Detail

CoolBarManager

public CoolBarManager()
Creates a new cool bar manager with the default style. Equivalent to CoolBarManager(SWT.NONE).


CoolBarManager

public CoolBarManager(int style)
Creates a cool bar manager with the given SWT style. Calling createControl will create the cool bar control.

Parameters:
style - the cool bar item style; see CoolBar for for valid style bits

CoolBarManager

public CoolBarManager(CoolBar coolBar)
Creates a cool bar manager for an existing cool bar control. This manager becomes responsible for the control, and will dispose of it when the manager is disposed.

Parameters:
coolBar - the cool bar control
Method Detail

add

public void add(IToolBarManager toolBarManager)
Description copied from interface: ICoolBarManager
A convenience method to add a tool bar as a contribution item to this cool bar manager. Equivalent to add(new ToolBarContributionManager(toolBarManager)).

Specified by:
add in interface ICoolBarManager
Parameters:
toolBarManager - the tool bar manager to be added
See Also:
ToolBarContributionItem

createControl

public CoolBar createControl(Composite parent)
Creates and returns this manager's cool bar control. Does not create a new control if one already exists.

Parameters:
parent - the parent control
Returns:
the cool bar control

itemAdded

protected void itemAdded(IContributionItem item)
Subclasses may extend this ContributionManager method, but must call super.itemAdded.

Overrides:
itemAdded in class ContributionManager
See Also:
ContributionManager.itemAdded(org.eclipse.jface.action.IContributionItem)

resetLayout

public void resetLayout()
Restores the canonical order of this cool bar manager. The canonical order is the order in which the contribution items where added.


dispose

public void dispose()
Disposes of this cool bar manager and frees all allocated SWT resources. Notifies all contribution items of the dispose. Note that this method does not clean up references between this cool bar manager and its associated contribution items. Use removeAll for that purpose.


getControl

public CoolBar getControl()
Returns the cool bar control for this manager.

Returns:
the cool bar control, or null if none

itemRemoved

protected void itemRemoved(IContributionItem item)
Subclasses may extend this ContributionManager method, but must call super.itemRemoved.

Overrides:
itemRemoved in class ContributionManager
See Also:
ContributionManager.itemRemoved(org.eclipse.jface.action.IContributionItem)

getStyle

public int getStyle()
Description copied from interface: ICoolBarManager
Returns the style of the underlying cool bar widget.

Specified by:
getStyle in interface ICoolBarManager
Returns:
the style of the cool bar

refresh

public void refresh()
Synchronizes the visual order of the cool items in the control with this manager's internal data structures. This method should be called before requesting the order of the contribution items to ensure that the order is accurate.

Note that update() and refresh() are converses: update() changes the visual order to match the internal structures, and refresh changes the internal structures to match the visual order.


update

public void update(boolean force)
Subclasses may extend this IContributionManager method, but must call super.update.

Specified by:
update in interface IContributionManager
Parameters:
force - true means update even if not dirty, and false for normal incremental updating
See Also:
IContributionManager.update(boolean)

getContextMenuManager

public IMenuManager getContextMenuManager()
Description copied from interface: ICoolBarManager
Returns the context menu manager used by this cool bar manager. This context menu manager is used by the cool bar manager except for cool items that provide their own.

Specified by:
getContextMenuManager in interface ICoolBarManager
Returns:
the context menu manager, or null if none
See Also:
ICoolBarManager.setContextMenuManager(org.eclipse.jface.action.IMenuManager)

setContextMenuManager

public void setContextMenuManager(IMenuManager contextMenuManager)
Description copied from interface: ICoolBarManager
Sets the context menu of this cool bar manager to the given menu manager.

Specified by:
setContextMenuManager in interface ICoolBarManager
Parameters:
contextMenuManager - the context menu manager, or null if none
See Also:
ICoolBarManager.getContextMenuManager()

getLockLayout

public boolean getLockLayout()
Description copied from interface: ICoolBarManager
Returns whether the layout of the underlying cool bar widget is locked.

Specified by:
getLockLayout in interface ICoolBarManager
Returns:
true if cool bar layout is locked, false otherwise

setLockLayout

public void setLockLayout(boolean value)
Description copied from interface: ICoolBarManager
Locks or unlocks the layout of the underlying cool bar widget. Once the cool bar is locked, cool items cannot be repositioned by the user.

Note that items can be added or removed programmatically even while the cool bar is locked.

Specified by:
setLockLayout in interface ICoolBarManager
Parameters:
value - true to lock the cool bar, false to unlock

setLayout

public void setLayout(ArrayList newLayout)
Replaces the internal data structure with the given new order. Then force and update.

Parameters:
newLayout - a list of new order of contribution items.

Eclipse Platform
Pre-release 3.0

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.